package com.open.yujiakj.core.interceptor;

import cn.dev33.satoken.stp.StpUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author honglei
 * @version 1.0
 * @description: TODO
 * @date 2025/5/23 20:46
 */
@Slf4j
@Component
public class PermissionInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String methon=request.getMethod();
        HttpServletMapping httpServletMapping=request.getHttpServletMapping();
        String stq=request.getRequestURI();
        String str1=request.getServletPath();
        String str2=request.getAuthType();
        log.info("1:{} 2:{} 3:{} 4:{} ",methon,stq,str1,str2 );
        StpUtil.checkPermission(stq);
        return HandlerInterceptor.super.preHandle(request, response, handler);
    }
}
